fixed head requests throwing errors for express 3.x - #75
Closed
trevorah wants to merge 1 commit into
Closed
Conversation
Contributor
|
I can't wait to get this dumb patching crap into it's own module :) It's in progress, haha. I'm fixing this now. |
Contributor
|
@trevorah can you verify |
Author
|
Yep, that fixes it and everything else is still working. |
Contributor
|
great :) i'll be bundled with a new express 3 today |
Author
|
hooray! |
|
Thank you, thank you, thank you! Was debugging this all morning. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In express 3.x, any HEAD request that uses express-session will throw a 500 error.
This is because
express/lib/response.jscallsthis.end(null, encoding)if the request is a HEAD request (see closest blame here).As the HEAD request just gets the headers for a particular resource, then the content length can also be set. This unfortunately means that the
res.endpatch attempts to create anew Buffer(null)which throws (usually whennode/lib/buffer.jsgetting the length property of null).This PR fixes it, with an extra test for
res.end(undefined)just to be sure.